var SUCCESS = 0;
var ERROR = 1;
var VALIDATION_ERROR = 2;
var ACCESS_DENIED = 3;
var CONFIRMATION = 4;
var BAD_CREDENTIALS = 5;

function lang(url, parameterValue) {

	replaceDuplicates = true;
	
	var parameterName = 'lang';

	if (url.indexOf('#') > 0) {
		var cl = url.indexOf('#');
		urlhash = url.substring(url.indexOf('#'), url.length);
	} else {
		urlhash = '';
		cl = url.length;
	}

	sourceUrl = url.substring(0, cl);

	var urlParts = sourceUrl.split("?");
	var newQueryString = "";

	if (urlParts.length > 1) {
		var parameters = urlParts[1].split("&");
		for ( var i = 0; (i < parameters.length); i++) {
			var parameterParts = parameters[i].split("=");
			if (!(replaceDuplicates && parameterParts[0] == parameterName)) {
				if (newQueryString == "")
					newQueryString = "?";
				else
					newQueryString += "&";
				newQueryString += parameterParts[0] + "=" + parameterParts[1];
			}
		}
	}
	if (newQueryString == "")
		newQueryString = "?";
	else
		newQueryString += "&";
	newQueryString += parameterName + "=" + parameterValue;

	location = urlParts[0] + newQueryString + urlhash;
	
	return false;
}
